package com.hnevc.yourhealthmanager.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.hnevc.yourhealthmanager.dto.WeightRecordDTO;
import com.hnevc.yourhealthmanager.entity.HealthPlane;
import com.hnevc.yourhealthmanager.entity.WeightRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface WeightRecordMapper extends BaseMapper<WeightRecord> {
    @Select("select id,user_id,weight,weight_time,weight_type from weight_record_table where user_id = #{userId}")
    List<WeightRecord> selectByUserId(@Param("userId") Integer userId);

    @Select("select wrt.id,user_id,username,wrt.weight,weight_time,weight_type " +
            "from weight_record_table as wrt, health_user_table as hut " +
            "where wrt.user_id= hut.id  and user_id = #{userId}")
    List<WeightRecordDTO> getWeightRecordListByUserId(@Param("userId") Integer userId);

       @Select("select wrt.id,user_id,username,wrt.weight,weight_time,weight_type " +
               "from weight_record_table as wrt, health_user_table as hut " +
               "where wrt.user_id= hut.id and  user_id = #{healthPlane.userId}  " +
               "and weight_time between #{healthPlane.startDate} and #{healthPlane.endDate} ")
    List<WeightRecordDTO> getWeightRecordListByHealthPlane(@Param("healthPlane") HealthPlane healthPlane);

    @Select("select wrt.id,user_id,username,wrt.weight,weight_time,weight_type " +
            "from weight_record_table as wrt, health_user_table as hut " +
            "where wrt.user_id= hut.id and wrt.user_id = #{healthPlane.userId} " +
            "and sport_date between #{healthPlane.startDate} and #{healthPlane.endDate}  " +
            "and Month(weight_time)=#{month} and Year(weight_time)=#{year}")
    List<WeightRecordDTO> getWeightRecordListByPlaneMonth(@Param("healthPlane") HealthPlane healthPlane,@Param("month") Integer month ,@Param("year") Integer year);

}